import type { AddressItem, AddressParams } from '@/types/address'
import type { OrderPreResult } from '@/types/order'
import { http } from '@/utils/http'

// /member/address 添加收货地址
export const newAddressAPI = (data: AddressParams) => {
  return http({
    method: 'POST',
    url: '/member/address',
    data,
  })
}
// 获取收货地址列表 GET/member/address
export const getAddressListAPI = () => {
  return http<AddressItem[]>({
    method: 'GET',
    url: '/member/address',
  })
}
// 获取收货地址详情
// GET/member/address/{id}
export const getMemberAddressByIdAPI = (id: string) => {
  return http<AddressItem>({
    method: 'GET',
    url: `/member/address/${id}`,
  })
}
// 修改收货地址
// PUT/member/address/{id}
// isDefault:是否为默认，1为是，0为否 ，注意：此处按照接口实现
export const putMemberAddressById = (id: string, data: AddressParams) => {
  return http({
    method: 'PUT',
    url: `/member/address/${id}`,
    data,
  })
}
// 删除收货地址
// Delete/member/address/{id}
// isDefault:是否为默认，1为是，0为否 ，注意：此处按照接口实现
export const deletetMemberAddressByIdAPI = (id: string) => {
  return http({
    method: 'DELETE',
    url: `/member/address/${id}`,
  })
}
